package thang.map.control;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;

import openones.corewa.BaseOutForm;

import org.apache.log4j.Logger;

import rocky.mvcportlet.control.BaseControl;
import thang.map.dao.AddData;
import thang.map.dao.GetData;
import thang.map.dataform.form.AddInForm;


public class AddControl extends BaseControl {
    static final Logger LOG = Logger.getLogger("MenuControl");

    public BaseOutForm procAddT(ActionRequest request,Map<String, Object> reqMap, ActionResponse response) throws PortletException, IOException {
        
        
        AddInForm form = new AddInForm();
        
        form = (AddInForm) getData(reqMap, AddInForm.class);
        
        LOG.debug("User name=:" + form.getName());
        LOG.debug("Birthday=:" + form.getAddress());
        String Name     = form.getName();
        String Address  = form.getAddress();
        String Birthday = form.getBirthday();
        
        AddData AD = new AddData();
        AD.Add(Name, Address, Birthday);
        LOG.debug("add.successfull");
        GetData GD = new GetData();
        List result = GD.Get();
        int length = result.size();
        LOG.debug("get.successfull");
        BaseOutForm resultForm = new BaseOutForm();
    
        resultForm.putSession("newlist", result);
        resultForm.putSession("lengthlist", length);
        
        
        /*resultForm.putRequest("newlist", result);
        resultForm.putRequest("lengthlist", length);*/
        return resultForm;
        
    }
    
    
    
}
